package com.lagou.edu.controller;

import com.lagou.edu.pojo.User;
import com.lagou.edu.service.UserService;
import com.lagou.edu.source.DataSourceInfo;
import com.lagou.edu.utils.ZookeeperFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 赵虎
 * @date 2020/11/30 12:17
 */
@RestController
public class IndexController {

    @Autowired
    private UserService userService;

    @GetMapping("/update")
    public String updateDataBase(DataSourceInfo dataSourceInfo) throws Exception {
        ZookeeperFactory zookeeperFactory = ZookeeperFactory.getInstance();
        zookeeperFactory.setPathValue(ZookeeperFactory.zkNodeName, dataSourceInfo);
        return "success";
    }

    @GetMapping("/list")
    public List<User> getUserList() {
        return userService.getUserList();
    }

}
